package com.zx.dsptuneup_TriMic.fragment;


import android.content.Context;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import android.text.InputType;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.TextView;

import com.example.base.tools.tools.StringUtils;
import com.google.android.material.tabs.TabLayout;
import com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar;
import com.hjq.toast.ToastUtils;
import com.zx.dsptuneup_TriMic.App;
import com.zx.dsptuneup_TriMic.Base.BaseFragment;
import com.zx.dsptuneup_TriMic.Common.circleView.ArcControlViewSmall;
import com.zx.dsptuneup_TriMic.Data_Bean.ChanelBean;
import com.zx.dsptuneup_TriMic.Data_Bean.EqSegmentBean;
import com.zx.dsptuneup_TriMic.Enum.MessageReceiveType;
import com.zx.dsptuneup_TriMic.ProtocolTools.ProtocolConversion;
import com.zx.dsptuneup_TriMic.R;
import com.zx.dsptuneup_TriMic.Tools.CVIPaperDialogUtils;
import com.zx.dsptuneup_TriMic.Tools.EventMessage;
import com.zx.dsptuneup_TriMic.Util.ClickUtil;
import com.zx.dsptuneup_TriMic.Util.Constants;
import com.zx.dsptuneup_TriMic.Util.UserUtil;
import com.zx.dsptuneup_TriMic.bean.BasicResponse;
import com.zx.dsptuneup_TriMic.network.DefaultObserver;
import com.zx.dsptuneup_TriMic.network.NetWorkManager;
import com.zx.dsptuneup_TriMic.widget.ui.MyFrequentTabLayout;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * A simple {@link Fragment} subclass.
 */
public class OutputDevelopFragment extends BaseFragment implements View.OnClickListener {
    @BindView(R.id.seg_tableLayout)
    MyFrequentTabLayout seg_tableLayout;

    @BindView(R.id.highcut_btn)
    Button highcut_btn;

    @BindView(R.id.lowcut_btn)
    Button lowcut_btn;

    @BindView(R.id.q_control)
    ArcControlViewSmall qControlView;

    @BindView(R.id.seg_freq_edt)
    EditText seg_freq_edt;

    @BindView(R.id.input_freq_sure_txt)
    TextView input_freq_sure;

    @BindView(R.id.gain_db_txt)
    TextView gain_db_txt;

    @BindView(R.id.q_show_txt)
    TextView q_show_txt;

    @BindView(R.id.eq_gain_seekbar)
    VerticalSeekBar eq_gain_seekbar;

    @BindView(R.id.plus)
    TextView plus;

    @BindView(R.id.minus)
    TextView minus;

    private View rootView;
    private String TAG = "OutputDevelopFragment";
    private int currentSelTitleIndex = Constants.channelEnum.line1;      //  头部标签选择
    private int currentSelFreqIndex = 0;                                //  当前选择的10段EQ的哪一段,注意跟上面属性的区别
    private int[] developChannelArr = {Constants.channelEnum.line1,Constants.channelEnum.line2,
            Constants.channelEnum.line3,Constants.channelEnum.line4,Constants.channelEnum.line5,
            Constants.channelEnum.line6,Constants.channelEnum.line7,Constants.channelEnum.line8}; // 对应开发者通道数据

    private final String[] freqArr = {"32","64","125","250","0.5k","1k","2k","4k","8k","16k"};
//    private String[] tagArr = {"1","2","3","4","5","6","7","8","9","10"};   // 标签

    //  高低切
    private int currentHighCutNum = 0;
    private int currentLowCutNum = 0;

    public OutputDevelopFragment() {
        // Required empty public constructor
    }

    @Override
    protected void initData() {}

    @Override
    protected void initVariables(Bundle bundle) {}

    @Override
    protected View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (null != rootView) {
            ViewGroup parent = (ViewGroup) rootView.getParent();
            if (null != parent) {
                parent.removeView(rootView);
            }
        } else {
            rootView = inflater.inflate(R.layout.fragment_input_develop, container, false);
            ButterKnife.bind(this, rootView);
            EventBus.getDefault().register(this);
            setupData();
        }

        return rootView;
    }

    /********************以下为页面seg切换的逻辑，分通道和eq分段*******************/
    /**
     *  EQ页面分通道的初始值
     * */
    private void resetNormalChanelUI() {
        ChanelBean chanelBean = App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex);

        // 1.设置高低切数据
        currentHighCutNum = chanelBean.getHighCut();
        currentLowCutNum = chanelBean.getLowCut();
        highcut_btn.setSelected(currentHighCutNum!=0);
        lowcut_btn.setSelected(currentLowCutNum  !=0);
        // 2.设置tab数据
        refreshTabUI();
        seg_tableLayout.getTabAt(0).select();
        // 3.重置tab下面的数据
        currentSelFreqIndex = 0;
        resetNormalEQSegUI();
    }

    /**
     *  EQ页面分段的初始值
     * */
    private void resetNormalEQSegUI() {
        EqSegmentBean currentSelEqSegmentBean = App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex);

        seg_freq_edt.setText("");
        // gain seekbar 和 q arcView显示

        eq_gain_seekbar.setProgress( (int)(currentSelEqSegmentBean.getGain()+72)* 2 );
        qControlView.setDB((int) (currentSelEqSegmentBean.getQvalue() * 10));

        //  gain_db_txt放在下面写，否则eq_gain_seekbar变成整形
        gain_db_txt.setText(currentSelEqSegmentBean.getGain()+"");
        q_show_txt.setText(currentSelEqSegmentBean.getQvalue()+"");

    }

    private void setupData() {
        // 下面这段代码防止页面随着软键盘弹出上移
        getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);

        ChanelBean chanelBean = App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex);
        //  设置高低切数据
//        highcut_btn.setSelected(chanelBean.getHighCut()!=0);
//        lowcut_btn.setSelected(chanelBean.getLowCut()!=0);
        highcut_btn.setVisibility(View.GONE);
        lowcut_btn.setVisibility(View.GONE);

        List<String> list = new ArrayList<>();
        for (EqSegmentBean eqSegmentBean : chanelBean.getEqSegArr()){
//            int index = chanelBean.getEqSegArr().indexOf(eqSegmentBean);

            list.add(eqSegmentBean.getEqSegName());

        }
        seg_tableLayout.setTitle(list);
        seg_tableLayout.getTabAt(0).select();
        seg_tableLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
        seg_tableLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {

                int position = tab.getPosition();
                if(position == currentSelFreqIndex){
                    return;
                }
                currentSelFreqIndex = position;
                resetNormalEQSegUI();

            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });


        /**
         *   -72 - 10 0.5步进
         *   *2 == -144 -  20
         *   progress 显示最小设置有api限制，设置从0 开始
         **/
        eq_gain_seekbar.setMax(164);
//        eq_gain_seekbar.setMin(-72);
//        eq_gain_seekbar.setProgress(qValueArr[i]+10);

        eq_gain_seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                gain_db_txt.setText((double)progress/2-72+" db");
                if(fromUser){
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                Log.d(TAG,"滑动停止");

                double gainValue = ((double)seekBar.getProgress() ) /2-72;

                App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex).setGain(gainValue);


                //  如果保存按钮不显示，不可以存eqtacticArr
                // 策略存储
//                    if(currentSelEQIndex>=0 && SaveEqBtn.getVisibility()==View.VISIBLE){
//                        eqtacticArr[currentSelEQIndex][equalizerIndex] = seekBar.getProgress()-10;
//                    }

                //  发送eq增益调节指令
                EqSegmentBean eqSegmentBean = App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex);
                int frequent = Integer.parseInt(eqSegmentBean.getEqSegName());
                double q_value = eqSegmentBean.getQvalue();
                double gain = gainValue;

                HashMap map = new HashMap();
                map.put("groups", UserUtil.currentSingleGroup);
                map.put("type", Constants.element_typeEnum.OUTPUT);
                map.put("channel",developChannelArr[currentSelTitleIndex]);
                map.put("line", currentSelFreqIndex);
                map.put("frequency", frequent);
                map.put("gain", gain);
                map.put("q", q_value);

                //查询指定音频处理器数据

                NetWorkManager.getInstance().getNetWorkApiService().setEQ(map).compose(OutputDevelopFragment.this.<BasicResponse<String>>bindToLifecycle())
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(new DefaultObserver<BasicResponse<String>>() {
                            @Override
                            protected void onSuccess(BasicResponse<String> response) {
                                if (response != null) {
                                    Log.e(TAG,"data==="+response.getData());
                                }
                            }
                            @Override
                            protected void onFail(BasicResponse<String> response) {
                                super.onFail(response);

                            }
                            @Override
                            public void onError(@NonNull Throwable e) {
                                super.onError(e);
                            }
                        });

//                App.getContext().getProtocolConversion().setEQ(ProtocolConversion.getFrameId(),Constants.operation_typeEnum.set_device,Constants.element_typeEnum.OUTPUT,developChannelArr[currentSelTitleIndex],currentSelFreqIndex,frequent,q_value,gain);
            }
        });

        /*以下是圆弧**/
        qControlView.setAngleRate(1);
        qControlView.setDB(0, 100, 0);
        //设置旋钮是否可旋转
        qControlView.setCanRotate(true);

        //  抬起才传值
        qControlView.setOnDbChangeListener(new ArcControlViewSmall.OnDbChangeListener() {
            @Override
            public void change(int db) {
                //  输出Q值
//                App.getContext().getHexadecimal().sendECHO(db/2);

                // 保留两位小数
                double qValue = (double)db/10;
                DecimalFormat df = new DecimalFormat("#.00");
                df.format(qValue);
                q_show_txt.setText( qValue + "");

                if(qValue==0){
                    qValue = 0.01;
                }
                Log.e("1111","qValue======"+qValue);

                App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex).setQvalue(qValue);

                EqSegmentBean eqSegmentBean = App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex);
                int frequent = Integer.parseInt(eqSegmentBean.getEqSegName());
                double q_value = qValue;
                double gain = eqSegmentBean.getGain();

                HashMap map = new HashMap();
                map.put("groups", UserUtil.currentSingleGroup);
                map.put("type", Constants.element_typeEnum.OUTPUT);
                map.put("channel",developChannelArr[currentSelTitleIndex]);
                map.put("line", currentSelFreqIndex);
                map.put("frequency", frequent);
                map.put("gain", gain);
                map.put("q", q_value);

                //查询指定音频处理器数据

                NetWorkManager.getInstance().getNetWorkApiService().setEQ(map).compose(OutputDevelopFragment.this.<BasicResponse<String>>bindToLifecycle())
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(new DefaultObserver<BasicResponse<String>>() {
                            @Override
                            protected void onSuccess(BasicResponse<String> response) {
                                if (response != null) {
                                    Log.e(TAG,"data==="+response.getData());
                                }
                            }
                            @Override
                            protected void onFail(BasicResponse<String> response) {
                                super.onFail(response);

                            }
                            @Override
                            public void onError(@NonNull Throwable e) {
                                super.onError(e);
                            }
                        });

//                App.getContext().getProtocolConversion().setEQ(ProtocolConversion.getFrameId(),Constants.operation_typeEnum.set_device,Constants.element_typeEnum.OUTPUT,developChannelArr[currentSelTitleIndex],currentSelFreqIndex,frequent,q_value,gain);
            }
        });
        //  move滑动时只显示数值
        qControlView.setOnDbMoveListener(new ArcControlViewSmall.OnDbMoveListener() {
            @Override
            public void moveChange(int db) {
                // 保留两位小数
                double qValue = (double)db/10;
                DecimalFormat df = new DecimalFormat("#.00");
                df.format(qValue);
                q_show_txt.setText( qValue + "");
            }
        });

        resetNormalChanelUI();

        highcut_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CVIPaperDialogUtils.showInputDialog(getActivity(), "请输入频率值", "确定", null, InputType.TYPE_CLASS_NUMBER,true, new CVIPaperDialogUtils.inputConfirmDialogListener() {
                    @Override
                    public void onClickButton(boolean clickConfirm, boolean clickCancel, String inputStr) {
                        if(clickConfirm && !StringUtils.isEmpty(inputStr)){
                            Log.e("inputStr===",inputStr);
                            int input = Integer.parseInt(inputStr);

                            if(input >=20 && input<=20000){
                                currentHighCutNum = input;
                                App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).setHighCut(input);
                                highcut_btn.setSelected(true);


                                App.getContext().getProtocolConversion().setHighLowCut(ProtocolConversion.getFrameId(),Constants.operation_typeEnum.set_device,Constants.element_typeEnum.OUTPUT,developChannelArr[currentSelTitleIndex],Constants.highLowCutEnum.high,input);
                            }else {
                                ToastUtils.show("请检查输入范围!");
                            }
                        }
                    }
                });
            }
        });

        lowcut_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                CVIPaperDialogUtils.showInputDialog(getActivity(), "请输入频率值", "确定",null,InputType.TYPE_CLASS_NUMBER, true, new CVIPaperDialogUtils.inputConfirmDialogListener() {
                    @Override
                    public void onClickButton(boolean clickConfirm, boolean clickCancel, String inputStr) {
                        if(clickConfirm && !StringUtils.isEmpty(inputStr)){
                            int input = Integer.parseInt(inputStr);
                            if(input >=20 && input<=20000){
                                currentLowCutNum = input;
                                App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).setLowCut(input);

                                lowcut_btn.setSelected(true);
                                App.getContext().getProtocolConversion().setHighLowCut(ProtocolConversion.getFrameId(),Constants.operation_typeEnum.set_device,Constants.element_typeEnum.OUTPUT,developChannelArr[currentSelTitleIndex],Constants.highLowCutEnum.low,input);
                            }else {
                                ToastUtils.show("请检查输入范围!");
                            }

                        }
                    }
                });
            }
        });

        input_freq_sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(getActivity().getWindow().getDecorView().getWindowToken(), 0); // 解决键盘无法关闭问题

                String inputStr = seg_freq_edt.getText().toString();
                if(!StringUtils.isEmpty(inputStr) ) {

                    int input = Integer.parseInt(inputStr);
                    if(input >=20 && input<=20000){
                        // 数据处理
                        App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex).setEqSegName(inputStr);


                        // 发送freqent 指令
                        EqSegmentBean eqSegmentBean = App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex);
                        double gain = eqSegmentBean.getGain();
                        double q_value = eqSegmentBean.getQvalue();

                        HashMap map = new HashMap();
                        map.put("groups", UserUtil.currentSingleGroup);
                        map.put("type", Constants.element_typeEnum.OUTPUT);
                        map.put("channel",developChannelArr[currentSelTitleIndex]);
                        map.put("line", currentSelFreqIndex);
                        map.put("frequency", input);
                        map.put("gain", gain);
                        map.put("q", q_value);

                        //查询指定音频处理器数据

                        NetWorkManager.getInstance().getNetWorkApiService().setEQ(map).compose(OutputDevelopFragment.this.<BasicResponse<String>>bindToLifecycle())
                                .subscribeOn(Schedulers.io())
                                .observeOn(AndroidSchedulers.mainThread())
                                .subscribe(new DefaultObserver<BasicResponse<String>>() {
                                    @Override
                                    protected void onSuccess(BasicResponse<String> response) {
                                        if (response != null) {
                                            Log.e(TAG,"data==="+response.getData());
                                        }
                                    }
                                    @Override
                                    protected void onFail(BasicResponse<String> response) {
                                        super.onFail(response);

                                    }
                                    @Override
                                    public void onError(@NonNull Throwable e) {
                                        super.onError(e);
                                    }
                                });

//                        App.getContext().getProtocolConversion().setEQ(ProtocolConversion.getFrameId(),Constants.operation_typeEnum.set_device,Constants.element_typeEnum.OUTPUT,developChannelArr[currentSelTitleIndex],currentSelFreqIndex,input,q_value,gain);
                        refreshTabUI();
                    }else {
                        ToastUtils.show("请检查输入范围!");
                    }
                }else {
                    ToastUtils.show("请输入数字!");
                }
            }
        });


        /**
         *  加减值 步进0.01
         * */
        plus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                double q_value =  App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex).getQvalue();
                if(q_value>=10 || q_value<0){
                    return;
                }
                q_value+=0.01;

                q_value = ((double) Math.round(q_value * 100))/100;
                q_show_txt.setText( q_value + "");

                App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex).setQvalue(q_value);
                Log.e("1111","qValue======"+q_value);

                EqSegmentBean eqSegmentBean = App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex);
                int frequent = Integer.parseInt(eqSegmentBean.getEqSegName());
                double gain = eqSegmentBean.getGain();

                HashMap map = new HashMap();
                map.put("groups", UserUtil.currentSingleGroup);
                map.put("type", Constants.element_typeEnum.OUTPUT);
                map.put("channel",developChannelArr[currentSelTitleIndex]);
                map.put("line", currentSelFreqIndex);
                map.put("frequency", frequent);
                map.put("gain", gain);
                map.put("q", q_value);

                //查询指定音频处理器数据

                NetWorkManager.getInstance().getNetWorkApiService().setEQ(map).compose(OutputDevelopFragment.this.<BasicResponse<String>>bindToLifecycle())
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(new DefaultObserver<BasicResponse<String>>() {
                            @Override
                            protected void onSuccess(BasicResponse<String> response) {
                                if (response != null) {
                                    Log.e(TAG,"data==="+response.getData());
                                }
                            }
                            @Override
                            protected void onFail(BasicResponse<String> response) {
                                super.onFail(response);

                            }
                            @Override
                            public void onError(@NonNull Throwable e) {
                                super.onError(e);
                            }
                        });

            }
        });

        minus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                double q_value =  App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex).getQvalue();
                if(q_value>10 || q_value<=0.01){
                    return;
                }
                q_value-=0.01;
                q_value = ((double) Math.round(q_value * 100))/100;
                q_show_txt.setText( q_value + "");

                App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex).setQvalue(q_value);
                Log.e("1111","qValue======"+q_value);

                EqSegmentBean eqSegmentBean = App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex).getEqSegArr().get(currentSelFreqIndex);
                int frequent = Integer.parseInt(eqSegmentBean.getEqSegName());
                double gain = eqSegmentBean.getGain();

                HashMap map = new HashMap();
                map.put("groups", UserUtil.currentSingleGroup);
                map.put("type", Constants.element_typeEnum.OUTPUT);
                map.put("channel",developChannelArr[currentSelTitleIndex]);
                map.put("line", currentSelFreqIndex);
                map.put("frequency", frequent);
                map.put("gain", gain);
                map.put("q", q_value);

                //查询指定音频处理器数据

                NetWorkManager.getInstance().getNetWorkApiService().setEQ(map).compose(OutputDevelopFragment.this.<BasicResponse<String>>bindToLifecycle())
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(new DefaultObserver<BasicResponse<String>>() {
                            @Override
                            protected void onSuccess(BasicResponse<String> response) {
                                if (response != null) {
                                    Log.e(TAG,"data==="+response.getData());
                                }
                            }
                            @Override
                            protected void onFail(BasicResponse<String> response) {
                                super.onFail(response);

                            }
                            @Override
                            public void onError(@NonNull Throwable e) {
                                super.onError(e);
                            }
                        });
            }
        });

    }

    /**
     * 收到消息
     *
     * @param message the message
     */
    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onGetStickyEvent(EventMessage message) {
        Log.d(TAG,"onReceiveMsg====" + message.toString());
        if (message.getType().equals(MessageReceiveType.OutputTitleIndexChange)){
            this.currentSelTitleIndex = Integer.parseInt(message.getMessage());
            //  选择的事EQ调节模块，点击title切换，EQ归默认值
            resetNormalChanelUI();
        }else if(message.getType().equals(MessageReceiveType.MessageRecOutput)){
        }
    }

    /**
     *  更换tab的title
     * */
    private void refreshTabUI() {
        ChanelBean chanelBean = App.getContext().getEqData().getOutputChannelArr().get(currentSelTitleIndex);
        List<String> list = new ArrayList<>();
        for (EqSegmentBean eqSegmentBean : chanelBean.getEqSegArr()){
//            int index = chanelBean.getEqSegArr().indexOf(eqSegmentBean);

            list.add(eqSegmentBean.getEqSegName());

        }
        seg_tableLayout.refreshTitles(list);
    }


    /**
     * dp转换成px
     *
     * @param dpValue the dp value
     * @return the int
     */
    public int dp2px(float dpValue){
        float scale=getResources().getDisplayMetrics().density;
        return (int)(dpValue*scale+0.5f);
    }


    @Override
    public void onClick(View v) {
        if (ClickUtil.isFastClick(1000, v)) {
            return;
        }



    }

}
